<template>
  <van-nav-bar
      fixed
      title="提现"
      left-text="返回"
      right-text="提现记录"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
  />
  <van-divider></van-divider>
  <van-divider></van-divider>
  <van-form @submit="onSubmit">
    <van-field
        v-model="money"
        name="金额"
        label="金额"
        placeholder="金额"
        :rules="[{ required: true, message: '请填写金额' }]"
    />
    <div style="margin: 16px;">
      <van-button round block type="primary" native-type="submit">
        提交
      </van-button>
    </div>
  </van-form>
</template>

<script>
import {withdraw} from "@/api/user";
import {Toast} from "vant";

export default {
  name: "Withdraw",
  data(){
    return {
      money:""
    }
  },
  methods:{
    onSubmit(){
      withdraw(this.money).then((res)=>{
        console.log(res)
        if(res.code!=200){
          Toast.fail(res.msg);
          return
        }
        Toast.success("操作成功")
      })
    },
    onClickRight(){
      this.$router.push('/withdraw-log')
    },
    onClickLeft(){
      this.$router.go(-1)
    }
  }
}
</script>

<style scoped>

</style>
